home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / GRAPHICS / TOOLS / TGDN / Docs / Extensions < prev    next >
Text File  |  1996-12-01  |  26KB  |  676 lines

  1.  
  2.                         Language Extensions
  3.                         ===================
  4.  
  5. 1.0 Introduction
  6. 2.0 The RMStore directory
  7. 3.0 Structure
  8. 4.0 Resources
  9. 5.0 Coding
  10. 6.0 Calling internal commands
  11.  
  12. 1.0 Introduction
  13. ~~~~~~~~~~~~~~~~
  14. This document describes how to write language-extensions to the texture
  15. generation language used in the Texture Garden program, reasons why you might
  16. be interested in doing this and information about installing other people's
  17. extension modules.
  18.  
  19. Commands may be included, but functions (refer to the "Language" file for the
  20. differences between these) may not currently be implemented by third parties.
  21.  
  22. Example source code using the BASIC assembler is available. It is no longer
  23. commonly distributed with the main TG archive (for reasons of space), and
  24. the entire source code for Texture Garden's Kernel is also available.
  25. Although this code is distributed as freeware (i.e. copyright is retained)
  26. the author expresses every intention of approving use of my code where it is
  27. incorporated into modules intended for my program, so please do not hesitate
  28. to steal and butcher it; if this was objected to no source code would have
  29. been distributed.
  30.  
  31. 2.0 The RMStore directory
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~
  33. This is a directory immediately inside the "!TexturGdn" directory.  The
  34. location is usually "<TextureGdn$Dir>.RMStore".  The precise location is held
  35. in the system variable <TextureGdnRMStore$Dir> which is usually set up in the
  36. !Run file.
  37.  
  38. This directory should always contain a text file called "Index".  This file
  39. has a simple format:
  40.  
  41. Any line starting with a "|" is considered to be a comment. The end of the
  42. file is marked by the "End" token. Any other lines are considered as paths
  43. from <TextureGdnRMStore$Dir> to files containing language extensions.
  44.  
  45. The file "Kernel" should always be present in the directory.  It contains all
  46. the commands implemented as the core of the language.  There may also be
  47. other files.
  48.  
  49. The files may be of any type.  Conventionally, they are "Modules"
  50. (Type &FFA).  Though they are not loaded as such by the program this enables
  51. them to conveniently contain a version number and help text.
  52.  
  53. When adding extension modules to the program the relevant file should be
  54. added to the "RMStore" directory and the twig of its path inserted into the
  55. "Index" file.
  56.  
  57. 3.0 Structure
  58. ~~~~~~~~~~~~~
  59. Language extensions should all conform to the following structure:
  60.  
  61. Bytes:        Description...
  62. &0000-&002B   Header (Undefined bytes)
  63. &002C-&XXXX   Command Table index
  64. &XXXX-&YYYY   Command Table
  65. &YYYY-&ZZZZ   Command code
  66.  
  67. The Command Table index has the following format:
  68.  
  69. Offset bytes: Description...
  70. &0000           Command index entry 0
  71. &000C          Command index entry 1
  72. &0018          Command index entry 2
  73. -             -
  74. n x &C        Command index entry n
  75. -             -
  76. &UUUU         End of table marker.
  77.  
  78. The End of table marker is represented by the three consecutive words 
  79. -1,-1 and -1.
  80.  
  81. Command index entry n consists of three words
  82.  
  83. Word 0: Offset from start of file to the text of command n.
  84. Word 1: Offset from start of file to the entry point of the code to perform
  85.         the command.
  86. Word 2: Various flags
  87.  
  88. The Various flags are considered as &ABCDEFGH where &A is the number of
  89. parameters the command accepts (0-15), &B is a code advising how the command
  90. should be treated by the mutator (the "Mutation Options"), and &CDEFGH
  91. contain other miscellaneous bit-flags to mark specific command types.
  92.  
  93. These bit-flags have the following meanings:
  94.  
  95. &000003 :                                           (Reserved)
  96. &00000C : See immediately below:
  97.      &4 : Command ends an indentation
  98.      &8 : Command starts an indentation
  99. &0000F0 :                                           (Reserved)
  100. &00FF00 : As follows:
  101.   &0C00 : Command is an "endif"                     (Reserved)
  102.   &0200 : Command starts mutation                   (Reserved)
  103.   &0300 : Command stops  mutation                   (Reserved)
  104.   &0400 : Command is a  "Define"                    (Reserved)
  105.   &0500 : Command is a  "Goto"                      (Reserved)
  106.   &0600 : Command is a  "Call"                      (Reserved)
  107.   &0700 : Command is a  "Return"                    (Reserved)
  108.   &0800 : Command is an "End"                         (Reserved)
  109.   &0900 : Command is an "If"                         (Reserved)
  110.   &0A00 : Command is an "Then"                      (Reserved)
  111.   &0B00 : Command is an "Else"                      (Reserved)
  112.   &0100 : Command is a  "comment" ("|")             (Reserved)
  113.   &0D00 : Command ends the colour definition        (Reserved)
  114.   &0E00 : Command starts the colour definition      (Reserved)
  115.   &0F00 : Command is a  "CreateOneDiensionalFilter" (Reserved)
  116.   &1000 : Command is a  "CreateTwoDiensionalFilter" (Reserved)
  117.   &1100 : Command is an "Until"                     (Reserved)
  118.   &1200 : Command is a  "Resize"                    (Reserved)
  119.   &1300 : Command is a  "ResizeSprite"              (Reserved)
  120.   &1400 : Command is a  "MakeSprite"                (Reserved)
  121.   &1500 : Command is an "AddToSprite"               (Reserved)
  122.   &1600 : Command is a  "MakeVirtualSprite"         (Reserved)
  123.   &1700 - &FF00 For expansion                       (Reserved)
  124. &FF0000 : Bits all for expansion and must be zero   (Reserved)
  125.  
  126. "Reserved" means that most users should not need to mess with it.
  127.  
  128. The "Command Table" contains the entries pointed to by word 0 of the Command
  129. index entry.  These are mixed case strings terminated by a single ASCII 13
  130. character.  They need not be word aligned.
  131.  
  132. The "Command code" contains the code pointed to by word 1 of the Command
  133. index entry.  These are ARM code subroutines called at the appropriate moment
  134. in the generation of the textures.  Any workspace may also be stored here,
  135. rather than claimed from the system, if it is small enough.  The location of
  136. the "Command code" relative to the "Command table" is arbitrary.
  137.  
  138. Mutation Options
  139. ~~~~~~~~~~~~~~~~
  140. This specifies how any following parameters are treated by the mutator.
  141. 0 - Completely ignore.
  142. 1 - Treat as unsigned 16-bit logarithmic number (reserved for functions)
  143. 2 - Very occasionally add or subtract one (used for "Shear")
  144. 3 - Occasionally completely randomize (used for "Seed")
  145. 4 - Treat as unsigned 16-bit logarithmic number
  146. 5 - Treat as a SetColour command...
  147. 6 - Treat as a DefineLightSource command.
  148. 7 - Reserved...
  149.  
  150. 4.0 Resources
  151. ~~~~~~~~~~~~~
  152. When a code fragment is called in the generation of a texture it may interact
  153. with the main program and share its data in a number of ways.
  154.  
  155. On entry to the routine the following register conventions are used:
  156.  
  157. R14 - return address
  158. R13 - system stack
  159. R12 - pointer to Texture Garden main data structure
  160. R11 - pointer to current point in texture program execution
  161.  
  162. On exit R0 - R10, R12 and R14 may be corrupted.  R11 should normally be
  163. incremented to the start of the next expected command.  R13 should normally
  164. be preserved in the normal manner.
  165.  
  166. R11 contains a pointer to the next item in the texture program's execution.
  167. This will always be the next item after the code representing the currently
  168. called command.  Note that the program is not held internally as a textfile,
  169. but in an internal format.
  170.  
  171. Each command, parameter or function is coded for by one word.  Parameters are
  172. coded for by their values.  Commands and functions are coded bu an internal
  173. number, the complete details of which are not specified, but which always has
  174. bit 31 set.  The end of the file is coded as -1.  This need not normally be
  175. checked for.
  176.  
  177. R12 contains a pointer to a data structure which has the following structure:
  178.  
  179. Brief list:
  180.  
  181. Routines
  182. ~~~~~~~~
  183. &0000 : TG_getrnd - routine returning 32bit random number in R3
  184. &0004 : TG_getrnd2 - routine returning 32bit random number in R3
  185. &0008 : TG_getparameter - routine returning the value of the next parameter
  186. &000C : TG_cstable - location of sin and cosine table.
  187. &0010 : TG_astable - location of arcsin table.
  188. &0014 : TG_forstac - location of stack of for addresses
  189. &0018 : TG_forcoun - location of stack of for addresses
  190. &001C : TG_itisthecodebank - location of 16 words of ARM code for "Combine"
  191. &0020 : TG_onedimensionalfixsta - routine to start one-dimensional routines
  192. &0024 : TG_onedimensionalfixend - routine to end one-dimensional routines
  193. &0028 : TG_colourconversion - routine to perform conversion from 24-bit
  194. &002C : TG_mcheap_get - allocate memory from heap
  195. &0030 : TG_mcheap_release - deallocate memory in heap
  196. &0034 : TG_reporterror - routine to report texture errors to the user
  197. &0038 : TG_executesinglecommand - Single command execution routine
  198. &003C : TG_convertcommandname - Converts pointer to command name
  199. &0040 : TG_miscop - perform a variety of operations.
  200. &0044 : Reserved
  201.  
  202. Data
  203. ~~~~
  204. &0048 : TG_mainworkspaceaddress - the two-dimensional buffer
  205. &004C : TG_totalsize - the size of the two-dimensional buffer
  206. &0050 : TG_totalsizeminusone - the size of the two-dimensional buffer - 1
  207. &0054 : TG_powertwo - Log to the base two of the size of the main buffer
  208. &0058 : TG_powertwo_1D - Log to the base two of the 1D buffer size (10).
  209. &005C : TG_dat - temp storage (4 bytes)
  210. &0060 : TG_stack_temp - temp storage (4 bytes)
  211. &0064 : TG_cnd - temp storage (4 bytes)
  212. &0068 : TG_scrapaddress - address of temp storage (at least &800 bytes.)
  213. &006C : TG_actualphase - Current phase to be used in FFTs
  214. &0070 : TG_actualnoise - Amplitude of noise to be filtered
  215. &0074 : TG_cosamag - Cosine artefacts magnitude
  216. &0078 : TG_sinamag - Sine artefacts magnitude
  217. &007C : TG_precultflags - flags for FFT
  218. &0080 : TG_tempb - temp storage (4 bytes)
  219. &0084 : TG_tempb2 - temp storage (4 bytes)
  220. &0088 : TG_onedeebuffertwo - the secondary two-dimensional buffer
  221. &008C : TG_onedeebufferone - the primary two-dimensional buffer
  222. &0090 : TG_onedeebuffer - the two-dimensional buffer
  223. &0094 : TG_forcntr - the depth of the current for nesting
  224. &0098 : TG_dithering - Dithering
  225. &009C : TG_ditheringOne - DitheringOne
  226. &00A0 : TG_ditheringTwo - DitheringTwo
  227. &00A4 : TG_resultoftestpar - internal communications
  228. &00A8 : TG_resultoftestparP4 - internal communications
  229. &00AC : TG_seed - Seed (Low word)
  230. &00B0 : TG_seedP4 - Seed (High word)
  231. &00B4 : TG_seedTwo - Seed Two (Low word)
  232. &00B8 : TG_seedTwoP4 - Seed Two (High word)
  233. &00BC : TG_aframesmem% - Number of current animation frame
  234. &00C0 : TG_aframetype% - Address of table of 1024 nibbles animation type
  235. &00C4 : TG_areweanimating - Flag
  236. &00C8 : TG_blockmem% - address of a temp storage bank
  237. &00CC : TG_block2mem% - address of a temp storage bank
  238. &00D0 : TG_spriteaddress - address of the current sprite
  239. &00D4 : TG_spritearea - address of the main sprite area
  240. &00D8 : TG_spritepaladdress - address of the current palette sprite
  241. &00DC : TG_spriteXoriginal - used in resizing sprite
  242. &00E0 : TG_spriteYoriginal - used in resizing sprite
  243. &00E4 : TG_spriteXactual - used in resizing sprite
  244. &00E8 : TG_spriteYactual - used in resizing sprite
  245. &00EC : TG_modenumber - Number of current mode
  246. &00F0 : TG_log2BPP - Log to the base two of the number of bits per pixel
  247. &00F4 : TG_XEigenFactor - The X Eigen Factor of the mode
  248. &00F8 : TG_YEigenFactor - The Y Eigen Factor of the mode
  249. &00FC : TG_cmd_ifmem - Number to detect "If"s with
  250. &0100 : TG_cmd_elsemem - Number to detect "Else"s with
  251. &0104 : TG_cmd_endifmem - Number to detect "Endif"s with
  252. &0108 : TG_cmd_define - Number to detect "Define"s with
  253. &010C : TG_cmd_ifyetq - Flag to detect if there has been an if on the line
  254. &0110 : TG_colourmapcorrupt - Set if TG_colourconversion has been called
  255. &0114 : TG_AddressOfSolidBlock - Address of last DefineSolidBlock command
  256. &0118 : TG_memorystoreone - Address of claimed memory to be released
  257. &011C : TG_memorystoretwo - Address of claimed memory to be released
  258. &0120 : TG_FirstDefinition - zero of address of first "Define" command
  259. &0124 : TG_CallStackMem - Not used
  260. &0128 : TG_customresize - Set if resizing is not done with "ResizeSprite"
  261. &012C : TG_percentage - Reflects the hourglass percentage
  262. &0130 : TG_red - The red component of the current colour (0-&FFFF)
  263. &0134 : TG_green - The green component of the current colour (0-&FFFF)
  264. &0138 : TG_blue - The blue component of the current colour (0-&FFFF)
  265. &013C : TG_lstable - The address of the light source table
  266. &0140 : TG_lscounter - The number of light sources defined so far
  267. &0144 : TG_Xresize - \ The values of the last parameters passed to
  268. &0148 : TG_Yresize - / either Resize or ResizeBumpMap
  269. &014C : TG_registered - 0 if the Freeware version is in use (read only)
  270.  
  271. Those "Routines" in the above list which may be called can be reached by
  272. using the following code:
  273.  
  274. MOV    R14,PC
  275. LDR    PC,[R12,#<TG_routineoffset>]
  276.  
  277. In the examples this is a macro called "calltg".
  278.  
  279. Descriptive list:
  280.  
  281. Routines
  282. ~~~~~~~~
  283. TG_getrnd (&0000)
  284.   Entry : none
  285.   Exit  : corrupts R4 returns 32bit random number in R3.
  286.  
  287. TG_getrnd2 (&0004)
  288.   Entry : none
  289.   Exit  : corrupts R0 returns 32bit random number in R3.
  290.   Notes : This command uses a different seed to the one above.
  291.  
  292. TG_getparameter (&0008)
  293.   Entry : R11 points to current mark in program.
  294.   Exit  : R10 returns the value of the next parameter.
  295.           R11 updated to point to next point in program.
  296.  
  297. TG_cstable (&000C)
  298. Location of sin and cosine table.  2048 words, format as follows:
  299.   Word0    : Cosine(2*PI/1024 x 0) x 2^15
  300.   Word1    :   Sine(2*PI/1024 x 0) x 2^15
  301.   Word2    : Cosine(2*PI/1024 x 1) x 2^15
  302.   Word3    :   Sine(2*PI/1024 x 1) x 2^15
  303.   Word4    : Cosine(2*PI/1024 x 2) x 2^15
  304.   Word5    :   Sine(2*PI/1024 x 2) x 2^15
  305.   ...      : ...
  306.   Word2046 : Cosine(2*PI/1024 x 1023) x 2^15
  307.   Word2047 :   Sine(2*PI/1024 x 1023) x 2^15
  308.  
  309. TG_astable (&0010)
  310.   Arcsin table.  256 bytes.
  311.  
  312. TG_forstac (&0014)
  313.   Location of stack of for addresses.
  314.  
  315. TG_forcoun (&0018)
  316.   Location of stack of for addresses.
  317.  
  318. TG_itisthecodebank (&001C)
  319.   Location of 16 words of ARM code for "Combine"
  320.   The words are as follows:
  321.  
  322.     &0 : CMP   A,#&10000
  323.     &1 : MOVS  A,A,LSR #16
  324.     &2 : MOVS  A,A,LSL #16
  325.     &3 : EorS  A,A,#&8000
  326.     &4 : ADDS  A,A,9
  327.     &5 : CMP   A,9
  328.     &6 : SUBS  A,A,9
  329.     &7 : MOVCS A,#&10000
  330.     &8 : RSBCS A,A,#&20000
  331.     &9 : RSBMI A,A,#&0
  332.     &A : MOVMI A,#&0
  333.     &B : MOVCC A,9
  334.     &C : MOVCS A,9
  335.     &D : SUBCS A,A,#1
  336.     &E : MOVS  A,A,LSR #1
  337.     &F : MULS  A,9,A
  338.  
  339. TG_onedimensionalfixsta (&0020)
  340.   Routine to start one-dimensional routines.
  341.  
  342. TG_onedimensionalfixend (&0024)
  343.   Routine to end one-dimensional routines.
  344.  
  345. TG_colourconversion (&0028)
  346.   Routine to perform conversion of the palette from 24-bit colour in the
  347.   format &RRGGBBXX to a series of bytes representing the colour number of
  348.   the colour for the mode.
  349.  
  350. TG_mcheap_get (&002C)
  351.   This allocates memory from Texture Garden's heap
  352.   Entry : R0 contains number of bytes requested.
  353.   Exit  : R0 : 0 (an error has occurred (V is also set), or...
  354.           R0 : contains a pointer to the memory.
  355.           R1 - R7 corrupted.
  356.  
  357.   Note: this routine returns an error by setting the V flag and setting R0
  358.         to 0.
  359.  
  360. TG_mcheap_release (&0030) 
  361.   This deallocates memory which has been previously allocated from Texture
  362.   Garden's heap.
  363.   Entry : R0 contains a pointer to the memory.
  364.   Exit  : R0 : 0 : an error has occurred (V is also set), or...
  365.           R0 : 1 : sucessful.
  366.           R1 - R7 corrupted.
  367.  
  368.   Note: this routine returns an error by setting the V flag and setting R0
  369.         to 0.
  370.  
  371. TG_reporterror (&0034)
  372.   Entry : R0 points to the error string
  373.   Exit  : *** This routine does not return ***
  374.  
  375. TG_executesinglecommand (&0038) - Single command execution routine.
  376.   Entry : R11 points to the command to be executed.
  377.   Exit  : R0 - R10 and R12 are corrupted.  R11 points to immediately after
  378.           the command.
  379.  
  380. TG_convertcommandname (&003C) - Converts pointer to command name.
  381.   Entry : R0 points to the command to be converted.
  382.   Exit  : R0 contains the corresponding internal command code.
  383.  
  384. TG_miscop (&0040) - Performs a variety of miscellaneous operations.
  385.   Entry : R0 contains the reason code, see the following list:
  386.   
  387.   Entry : R0 = 0;
  388.     Allocate memory for another two dimensional buffer, if required and
  389.     return a pointer to it in R10.
  390.   Exit : R0 to R9 are corrupted.
  391.   
  392.   Entry : R0 = 1;
  393.     Allocate memory for a virtual sprite if required and return a pointer to
  394.     it in R10.
  395.   Exit : R0 to R9 are corrupted.
  396.   
  397.   Entry : R0 = 2; R1,R2,R3 are as "OS_SpriteOp" with R0 = &22E.
  398.     Delete columns from an existing sprite.  This is equivalent to
  399.     XOS_SpriteOp with R0 = &22E, except that it does not produce errors when
  400.     applied to deep sprites on pre-RISC OS 3.5 machines.
  401.   Exit : R10 is are corrupted.
  402.   
  403.   Entry : R0 = 3;
  404.     Allocate memory for a virtual palette sprite if required and return a
  405.     pointer to it in R10.
  406.   Exit : R0 to R9 are corrupted.
  407.   
  408. All other TG_miscop reason codes are reserved.
  409.  
  410. 5.0 Coding
  411. ~~~~~~~~~~
  412. Example source (in the BASIC assembler) should be available in the
  413. "Library.Source.Extra" file and the "Library.Source.Kernel" file.  These
  414. files are no longer distributed with most versions of Texture Garden, but
  415. should be available from its main web site.
  416.  
  417. If a command takes longer than about 0.2 seconds, then it should check the
  418. escape key at regular intervals (using an INKEY(minus) equivalent) and
  419. terminate if it is pressed.
  420.  
  421. On entry to its routine, a command usually starts by getting its relevant
  422. parameters.  These should always be checked to see if they are functions, and
  423. evaluated if this is the case.  It is recommended that the following code be
  424. used to get each one:
  425.  
  426. LDR    R10,[R11],#4
  427. TST    R10,#&80000000
  428. MOVNE  R14,PC
  429. LDRNE  PC,[R12,#TG_getparameter]
  430.  
  431. This is used so frequently that it really cries out to be a macro. 
  432. "getrecursiveparam" is its name in the examples.
  433.  
  434. The "Routine" TG_getparameter will normally preserve R0-R7, R12 and R13.  R8
  435. and R9 may be corrupted.  R10 contains the returned result of the function. 
  436. R11 is updated to point to the next word of interest.
  437.  
  438. Another command which will be used frequently relates to the implementation
  439. of the "combination type" commands.  Programmers may implement these in
  440. whatever manner they choose.  The author finds them to be best implemented
  441. using the following self-modifying code for speed, though this may cause a
  442. speed penalty for those with StrongARM chips.
  443.  
  444. In my routines, the following functions are used.
  445.  
  446. DEFFNgetaddparam(alse%)   ... corrupts R0-R3
  447. [OPT Pass%
  448.         LDR    0,[C,#TG_itisthecodebank]
  449.         ADR    1,alse%
  450.         And    2,R10,#&F
  451.         LDR    3,[0,2,ASL #2]
  452.         STR    3,[1]
  453.         MOV    R10,R10,LSR #4
  454.         And    2,R10,#&F
  455.         LDR    3,[0,2,ASL #2]
  456.         STR    3,[1,#4]
  457.         MOV    R10,R10,LSR #4
  458.         And    2,R10,#&F
  459.         LDR    3,[0,2,ASL #2]
  460.         STR    3,[1,#8]
  461.         MOV    R10,R10,LSR #4
  462.         And    2,R10,#&F
  463.         LDR    3,[0,2,ASL #2]
  464.         STR    3,[1,#12]
  465.         
  466.         MOV    0,#1
  467.         ADD    2,1,#12
  468.         SWI    &2006E ; REM XOS_SynchroniseCodeAreas
  469. ]
  470. = Pass%
  471.  
  472. DEFFNfourwords
  473. [OPT Pass%
  474.         MOV    R10,R10
  475.         MOV    R10,R10
  476.         MOV    R10,R10
  477.         MOV    R10,R10
  478. ]
  479. = Pass%
  480.  
  481. These are called as follows...
  482.  
  483. .command_entry
  484. ...
  485. OPT    FNgetrecursiveparam           ...see above
  486. OPT    FNgetaddparam(code_insertion)
  487. ...
  488. .code_insertion
  489. OPT    FNfourwords
  490. ...
  491.  
  492. The two values to be combined should be held in R9 (old) and R10 (new value)
  493. when "code_insertion" is reached.  The data table at TG_itisthecodebank
  494. contains the following pieces of code:
  495.  
  496. CMP    A,#&10000   ; 0
  497. MOVS   A,A,LSR #16 ; 1
  498. MOVS   A,A,LSL #16 ; 2
  499. EorS   A,A,#&8000  ; 3
  500. ADDS   A,A,9       ; 4
  501. CMP    A,9         ; 5
  502. SUBS   A,A,9       ; 6
  503. MOVCS  A,#&10000   ; 7
  504. RSBCS  A,A,#&20000 ; 8
  505. RSBMI  A,A,#&0     ; 9
  506. MOVMI  A,#&0       ; A
  507. MOVCC  A,9         ; B
  508. MOVCS  A,9         ; C
  509. SUBCS  A,A,#1      ; D
  510. MOVS   A,A,LSR #1  ; E
  511. MULS   A,9,A       ; F
  512.  
  513. Examination of FNgetaddparam should reveal that four values from the above
  514. table are taken according to the value of the four nibbles of the given
  515. parameter and stored at "code_insertion", least-significant nibble first.
  516.  
  517. 6.0 Calling internal commands
  518. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  519. "TG_executesinglecommand" and "TG_convertcommandname" may be used by commands
  520. to call other commands directly.  This is done in a crude manner,
  521. constructing the command in memory, and then setting the command pointer to
  522. point to it and then calling Texture Garden.
  523.  
  524. "TG_convertcommandname" should be used to convert the command name to a
  525. command code.  This step is important, as command codes are not guaranteed
  526. to be the same across different instantiations of the program, and they
  527. depend on which extension modules are loaded.  They only need to be
  528. calculated once each time Texture Garden is run.
  529.  
  530. Commands should be stored in memory locally and followed by any parameters.
  531. Commands may be of any case, and may be abbreviated by using the "."
  532. character (however, using this feature is very bad practise).  
  533. After the command codes and their parameters are all placed into consecutive
  534. words of memory, the current value of the command pointer (usually in R11)
  535. should then be saved, the location of the command to be executed should be
  536. loaded into R11 and "TG_executesinglecommand" should be called.
  537. Then the command pointer should be recovered from wherever it was saved.
  538.  
  539. Note: "TG_executesinglecommand" executes one command only.  The command
  540. should not be a comment or one of "If", "Then" or "Else"; the functionality
  541. of these may be mimicked manually.
  542.  
  543. Expression evaluation may be performed using a similar method, ie. set up the
  544. expression in coded form in memory, store R11, set R11 to point to the
  545. expression, and then use FNgetrecursiveparam (or its equivalent macro - see
  546. above) to evaluate it, restoring R11 afterwards.
  547.  
  548. The only functions in Texture Garden that currently use this functionality
  549. are the "SlowRotate" commands.  These use the "TwoDimensionalPoint" function
  550. to help them with their anti-aliasing.
  551.  
  552. In principle, any commonly used subroutine may be more efficiently
  553. implemented as a hard-wired command using this technique.
  554.  
  555. Because "TG_convertcommandname" performs a slow lookup, a number of common
  556. expression evaluation functions are assigned particular code numbers.
  557.  
  558. The following command names are guaranteed to be given numbers as follows:
  559.  
  560. &80000000 - "UnknownCommand" ; please do not use.
  561. &80000001 - "Combine"
  562. &80000002 - "ScaledSignedMultiply"
  563. &80000003 - "SignedMultiply"
  564. &80000004 - "PartlyScaledSignedMultiply"
  565. &80000005 - "PartlyScaledMultiply"
  566. &80000006 - "Divide"
  567. &80000007 - "Eor"
  568. &80000008 - "And"
  569. &80000009 - "Or"
  570. &8000000A - "LogicalShiftLeft"
  571. &8000000B - "LogicalShiftRight"
  572. &8000000C - "ArithmeticShiftLeft"
  573. &8000000D - "ArithmeticShiftRight"
  574. &8000000E - "Absolute"
  575. &8000000F - "Variable"
  576. &80000010 - "Random"
  577. &80000011 - "SimpleAddition"
  578. &80000012 - "UnboundedAddition"
  579. &80000013 - "CeilingAddition"
  580. &80000014 - "HalvingAddition"
  581. &80000015 - "SimpleSubtraction"
  582. &80000016 - "UnboundedSubtraction"
  583. &80000017 - "FloorSubtraction"
  584. &80000018 - "HalvingSubtraction"
  585. &80000019 - "Maximise"
  586. &8000001A - "Minimise"
  587. &8000001B - "Overwrite"
  588. &8000001C - "PositiveOverwrite"
  589. &8000001D - "Preserve"
  590. &8000001E - "Multiplication"
  591. &8000001F - "ScaledMultiplication"
  592. &80000020 - "Zeroise"
  593. &80000021 - "True"
  594. &80000022 - "False"
  595. &80000023 - "Zero"
  596. &80000024 - "Ninety"
  597. &80000025 - "OneHundredAndEighty"
  598. &80000026 - "TwoHundredandSeventy"
  599. &80000027 - "FloydSteinberg"
  600. &80000028 - "IsLessThan"
  601. &80000029 - "IsGreaterThan"
  602. &8000002A - "IsLessThanOrEqualTo"
  603. &8000002B - "IsGreaterThanOrEqualTo"
  604. &8000002C - "SignedIsLessThan"
  605. &8000002D - "SignedIsGreaterThan"
  606. &8000002E - "SignedIsLessThanOrEqualTo"
  607. &8000002F - "SignedIsGreaterThanOrEqualTo"
  608. &80000030 - "IsEqualTo"
  609. &80000031 - "IsNotEqualTo"
  610. &80000032 - "Sin"
  611. &80000033 - "Cos"
  612. &80000034 - "SignedSin"
  613. &80000035 - "SignedCos"
  614. &80000036 - "SquareRoot"
  615. &80000037 - "Noise"
  616. &80000038 - "PinkNoise"
  617. &80000039 - "QuickNoise"
  618. &8000003A - "BandpassNoise"
  619. &8000003B - "BandpassQuickNoise"
  620. &8000003C - "FractalNoise"
  621. &8000003D - "ShiftedSymmetricNoise"
  622. &8000003E - "ShiftedSymmetricPinkNoise"
  623. &8000003F - "ShiftedNoise"
  624. &80000040 - "ShiftedPinkNoise"
  625. &80000041 - "ShiftedSymmetricQuickNoise"
  626. &80000042 - "ShiftedQuickNoise"
  627. &80000043 - "ShiftedSymmetricFractalNoise"
  628. &80000044 - "ShiftedFractalNoise"
  629. &80000045 - "TwoDimensionalPoint"
  630. &80000046 - "QuickTwoDimensionalPoint"
  631. &80000047 - "OneDimensionalPoint"
  632. &80000048 - "QuickOneDimensionalPoint"
  633. &80000049 - "OneDimensionalPointOne"
  634. &8000004A - "QuickOneDimensionalPointOne"
  635. &8000004B - "OneDimensionalPointTwo"
  636. &8000004C - "QuickOneDimensionalPointTwo"
  637. &8000004D - "X"
  638. &8000004E - "Y"
  639. &8000004F - "Z"
  640. &80000050 - "Size"
  641. &80000051 - "LogSize"
  642. &80000052 - "LogBitsPerPixel"
  643. &80000053 - "AnimationType"
  644. &80000054 - "AnimationFrameNumber"
  645. &80000055 - "Add"
  646. &80000056 - "Subtract"
  647. &80000057 - "Maximise"
  648. &80000058 - "Minimise"
  649. &80000059 - "Multiply"
  650. &8000005A - "RGB"
  651. &8000005B - "HSV"
  652. &8000005C - "CIE"
  653. &8000005D - ... reserved.
  654.  
  655. These functions all preserve R0-R7 and return their value in R10, updating
  656. R11 according to the number of parameters they take.  They operate by
  657. evaluating their parameters in a recursive fashion.
  658.  
  659. X-, Y- and Z-based functions are expecting to find their values in R2, R3 and
  660. R4 respectively, and they depend upon this for their operation.
  661. Functions which fit into this category include those from "Noise" to
  662. "ShiftedFractalNoise" as well as the more obvious "X", "Y" and "Z".  These
  663. functions will not return sensible vaules unless R2, R3 and R4 are set up
  664. probably before they are called.
  665.  
  666. In general, different copies of Texture Garden will use different coding
  667. schemes for the numbers they assign to their commands.  It is recommended
  668. that you do not rely on the numbers given to commands (apart from those
  669. explicitly mentioned in the list above) as being constant, though within
  670. any given instantiation of Texture Garden, they will not change, so commands
  671. only need to be looked up once.
  672.  
  673. More information relating to writing extension modes is contained in the rest
  674. of the documentation, notably the "Distribute", "Language" and "Technical"
  675. files.
  676.